package com.lagou.redistest;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;

import java.util.HashSet;
import java.util.Set;

@SpringBootApplication
public class RedisTestApplication {
    public static void main(String[] args) {
        SpringApplication.run(RedisTestApplication.class, args);

        Set<HostAndPort> hosts = new HashSet<>();
        for (int port = 7001; port <= 7008; ++port) {
            hosts.add(new HostAndPort("172.16.0.9", port));
        }

        JedisCluster jedisCluster = new JedisCluster(hosts);
        jedisCluster.set("xlw", "ok");

        String value = jedisCluster.get("xlw");
        System.out.println(value);
    }

}
